<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3>Stakeholder Analytics Subscription</h3>
        Here you can change the Transaction Analytics subscription status of Stakeholders.<br/>
        When a Stakeholder is subscribed to Transaction Analytics, it will be billed monthly according to <br/>
        the analytics subscription fee based on the Stakeholder's tier.
        <br/>
        <br/>
        <h5>Change A Stakeholder's Subscription Status</h5>
        You can use the input fields in the table headers to filter out Stakeholders.
        <br/>
        <br/>
        <p:panel id="TTAsubscribersPanel">

            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>


            <h:form>
                <p:dataTable id="TTAsubscribersTable" value="#{stakeholderAccountsManagerBean.getAllStakeholders()}" var="o" paginator="true" rows="50"
                             >

                    <p:column headerText="Stakeholder Name" filterBy="#{o.name}" filterMatchMode="contains">
                        #{o.name}
                    </p:column>

                    <p:column headerText="Category" filterBy="#{o.category.description}" filterMatchMode="contains">
                        #{o.category.description}
                    </p:column>

                    <p:column headerText="Tier" filterBy="#{o.getStakeholderTier().getName()}" filterMatchMode="contains" >
                        #{o.getStakeholderTier().getName()}
                    </p:column> 

                    <p:column>
                        <f:facet name="header">Analytics <br/>Subscription</f:facet>
                        #{o.purchaseBI}
                    </p:column> 

                    <p:column>
                        <f:facet name="header">Make Subscribed?</f:facet>
                        <p:commandButton  value="YES" 
                                          action="#{stakeholderAccountsManagerBean.changeStakeholderAnalyticSubscription(true, o.name)}"
                                          update="TTAsubscribersPanel"
                                          >
                        </p:commandButton>
                        &nbsp;
                        <p:commandButton  value="NO" 
                                          action="#{stakeholderAccountsManagerBean.changeStakeholderAnalyticSubscription(false, o.name)}"
                                          update="TTAsubscribersPanel"
                                          >
                        </p:commandButton>
                        <br/>
                    </p:column> 

                </p:dataTable>
            </h:form>

        </p:panel>




    </ui:define>
</ui:composition>

